package com.sofwin.controller.contents;

import com.sofwin.dto.HumanResourceDto;
import com.sofwin.pojo.CEmployee;
import com.sofwin.pojo.CHumanResource;
import com.sofwin.pojo.CManager;
import com.sofwin.service.contents.EmployeeService;
import com.sofwin.service.contents.HumanResourceService;
import com.sofwin.service.contents.ManagerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

/**
 * @Project: ssm-parent
 * @Description: 人力资源Controller
 * @Author : abiao
 * @date Date : 2021年04月25日 上午 10:55
 */
@Controller
@RequestMapping("skip/humanResources")
public class SkipHumanResourceController {

    @Autowired
    private HumanResourceService humanResourceService;
    @Autowired
    private ManagerService managerService;
    @Autowired
    private EmployeeService employeeService;

    /**
    * @Author abiao
    * @Description  TODO
    * @Date 2021/4/25 下午 3:18
    * @param humanResource 人力资源
    * @param manager 管理层
    * @param employee 员工层
    * @param model 数据
    * @return String 视图
    */
    @RequestMapping("data")
    public String toHumanResources(CHumanResource humanResource, CManager manager, CEmployee employee, Model model){
        HumanResourceDto humanResourceDto = humanResourceService.selectHumanResources(humanResource);
        Integer humanId = humanResourceDto.getId();
        List<CEmployee> cEmployees = employeeService.selectEmployee(humanId);
        model.addAttribute("HR",humanResourceDto);
        model.addAttribute("employee",cEmployees);
        return "c_information/contents/humanResources";
    }
    @RequestMapping("managerDesc")
    public String toManagerDesc(CManager cManager,Model model){
        List<CManager> managers = managerService.selectManagerDesc(cManager.getId());
        model.addAttribute("manager",managers);
        return "c_information/contents/humanDesc";
    }
}
